package com.iss.itemplate.service.imp;

import com.iss.itemplate.dao.HelloDao;
import com.iss.itemplate.domain.App;
import com.iss.itemplate.dto.AppDto;
import com.iss.itemplate.service.GenericService;
import com.iss.itemplate.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * **********************************************************************
 * <p/>
 * iServiceSoft Inc © - 2009 All Rights Reserved
 * _____________________________________________
 * <p/>
 * NOTICE:  All information contained herein is, and remains
 * the property of iServiceSoft. Intellectual and technical concepts
 * contained herein are proprietary of iServiceSoft and may be covered
 * by U.S. and Foreign Patents, patents in process, and are protected
 * by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from iServiceSoft Incorporated.
 * <p/>
 * ***********************************************************************
 */

@Service("helloService")
public class HelloServiceImp extends GenericService implements HelloService {
   @Autowired
   @Qualifier("helloDaoJpa")
   private HelloDao helloDao;

   @Override
   public String getAppName () {
      return helloDao.getAppName();
   }

   @Override
   public AppDto getApp() {
      return mapper.map(helloDao.getApp(), AppDto.class, APP_INFO);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED)
   public void insertApp(AppDto appDto) {
      App app = mapper.map(appDto, App.class, APP_INFO);
      helloDao.insert(app);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED)
   public void updateApp(AppDto appDto) {
      App app = mapper.map(appDto, App.class, APP_INFO);
      helloDao.update(app);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED)
   public void deleteApp(Long appId) {
      App app = helloDao.findById(appId);
      helloDao.delete(app);
   }
}
